package com.taoym.voucher.xcx.service.impl;

import com.taoym.voucher.common.enums.ClickTypeEnum;
import com.taoym.voucher.common.utils.ThreadLocalUtils;
import com.taoym.voucher.xcx.domain.XcxClickRecord;
import com.taoym.voucher.xcx.entity.dto.XcxAddClickRecordDTO;
import com.taoym.voucher.xcx.mapper.XcxClickRecordMapper;
import com.taoym.voucher.xcx.service.XcxClickRecordService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDateTime;

/**
 * @coder taoym
 * @datetime 2021/8/19 17:19
 * @desc
 */
@Service
public class XcxClickRecordServiceImpl implements XcxClickRecordService {

    @Resource
    private XcxClickRecordMapper xcxClickRecordMapper;

    @Override
    public Integer addClickRecord(XcxAddClickRecordDTO data) {

        XcxClickRecord record = new XcxClickRecord();
        record.setClickType(data.getClickType());
        record.setActName(ClickTypeEnum.getActName(data.getClickType()));
        record.setUid(ThreadLocalUtils.get().getUid());
        record.setCreateTime(LocalDateTime.now());

        return xcxClickRecordMapper.insert(record);
    }
}
